gridpack::math::BaseVectorInterface< T, I > Class Template Reference

#include <vector_interface.hpp>

Inheritance diagram for gridpack::math::BaseVectorInterface< T, I >:
Inheritance graph
[legend]
Collaboration diagram for gridpack::math::BaseVectorInterface< T, I >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T TheType
typedef I IdxType

Public Member Functions

 BaseVectorInterface (void)
 Default constructor.
 ~BaseVectorInterface (void)
 Destructor.
IdxType size (void) const
 Get the global length.
IdxType localSize (void) const
 Get the local length.
void localIndexRange (IdxType &lo, IdxType &hi) const
 Get the local min/max global indexes.
void setElement (const IdxType &i, const TheType &x)
 Set an individual element.
void setElementRange (const IdxType &lo, const IdxType &hi, TheType *x)
 Set a range of elements (lo to hi-1).
void setElements (const IdxType &n, const IdxType *i, const TheType *x)
 Set an several elements.
void addElement (const IdxType &i, const TheType &x)
 Add to an individual element.
void addElements (const IdxType &n, const IdxType *i, const TheType *x)
 Add to an several elements.
void addElementRange (const IdxType &lo, const IdxType &hi, TheType *x)
 Add to a range of elements (lo to hi-1).
void getElement (const IdxType &i, TheType &x) const
 Get an individual element.
void getElements (const IdxType &n, const IdxType *i, TheType *x) const
 Get an several elements.
void getElementRange (const IdxType &lo, const IdxType &hi, TheType *x) const
 Get a range of elements (lo to hi-1).
void getAllElements (TheType *x) const
 Get all of vector elements (on all processes).
void zero (void)
 Make all the elements zero.
void fill (const TheType &v)
 Make all the elements the specified value.
void scale (const TheType &x)
 Scale all elements by a single value.
double norm1 (void) const
 Compute the vector L1 norm (sum of absolute value).
double norm2 (void) const
 Compute the vector L2 norm (root of sum of squares).
double normInfinity (void) const
 Compute the infinity (or maximum) norm.
void abs (void)
 Replace all elements with its absolute value (complex magnitude).
void real (void)
 Replace all elements with their real part.
void imaginary (void)
 Replace all elements with their imaginary part.
void conjugate (void)
 Replace all elements with their complex conjugate.
void exp (void)
 Replace all elements with its exponential.
void reciprocal (void)
 Replace all elements with its reciprocal.
void ready (void)
 Make this instance ready to use.
void print (const char *filename=NULL) const
 Print to named file or standard output.
void save (const char *filename) const
 Save, in MatLAB format, to named file (collective).
void loadBinary (const char *filename)
 Load from a named file of whatever binary format the math library uses.
void saveBinary (const char *filename) const
 Save to named file in whatever binary format the math library uses.

Detailed Description

template<typename T, typename I = int>
class gridpack::math::BaseVectorInterface< T, I >

This defines the basic interface for vectors.


Member Typedef Documentation

template<typename T, typename I = int>
typedef I gridpack::math::BaseVectorInterface< T, I >::IdxType

The size/index type used

Reimplemented in gridpack::math::VectorT< T, I >, and gridpack::math::VectorImplementation< T, I >.

template<typename T, typename I = int>
typedef T gridpack::math::BaseVectorInterface< T, I >::TheType

Constructor & Destructor Documentation

template<typename T, typename I = int>
gridpack::math::BaseVectorInterface< T, I >::BaseVectorInterface ( void   ) 

Default constructor.

template<typename T, typename I = int>
gridpack::math::BaseVectorInterface< T, I >::~BaseVectorInterface ( void   ) 

Destructor.


Member Function Documentation

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::abs ( void   ) 

Replace all elements with its absolute value (complex magnitude).

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::addElement ( const IdxType i,
const TheType x 
)

Add to an individual element.

Local.

Parameters:
i 
x 
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::addElementRange ( const IdxType lo,
const IdxType hi,
TheType x 
)

Add to a range of elements (lo to hi-1).

Local.

An example that adds to the the locally owned part of the vector:

 {.cpp}
 Vector v(...);
 int lo, hi;
 v.local_index_range(lo, hi);
 std::vector<ComplexType> x(v.local_size())
 // fill x with appropriate values
 v.addElement_range(lo, hi, &x[0]);
Parameters:
lo lowest global (0-based) index to fill
hi one more than the highest global (0-based) index to fill
x array of hi - lo values
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::addElements ( const IdxType n,
const IdxType i,
const TheType x 
)

Add to an several elements.

Local.

Parameters:
n 
i 
x 
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::conjugate ( void   ) 

Replace all elements with their complex conjugate.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::exp ( void   ) 

Replace all elements with its exponential.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::fill ( const TheType v  ) 

Make all the elements the specified value.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::getAllElements ( TheType x  )  const

Get all of vector elements (on all processes).

Collective.

This is an all gather operation and consequently will be slow. All of this vector's elements are gathered on all processes and placed in the in the specified array.

Parameters:
x array of size() length to be filled with values
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::getElement ( const IdxType i,
TheType x 
) const

Get an individual element.

Local.

Only local values may be retreived with this method.

Parameters:
i element's global, 0-based index
x element's value
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::getElementRange ( const IdxType lo,
const IdxType hi,
TheType x 
) const

Get a range of elements (lo to hi-1).

Local.

The elements whose indexes range from lo to hi-1 are retreived. Only local values may be retreived with this method. The length of the x array must be at least "hi - lo"

Parameters:
lo lowest element index
hi one more than the highest element index
x existing array of values to be filled with element values
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::getElements ( const IdxType n,
const IdxType i,
TheType x 
) const

Get an several elements.

Local.

Only local values may be retreived with this method.

Parameters:
n number of elements to get
i array of n global, 0-based indexes
x array of n values
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::imaginary ( void   ) 

Replace all elements with their imaginary part.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::loadBinary ( const char *  filename  ) 

Load from a named file of whatever binary format the math library uses.

Collective.

The underlying math library generally supports some way to save a Vector to a file. This will load elements from a file of that format.

Parameters:
filename 
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::localIndexRange ( IdxType lo,
IdxType hi 
) const

Get the local min/max global indexes.

Local.

The minimum index in the first global (0-based) index owned by the local process. The maximum is one more than the last global index owned. An example of usage:

 {.cpp}
     int lo, hi;
     my_vector.local_index_range(lo, hi);
     for (int i = lo; i < hi; ++i) {
       ComplexType x;
       x = ...;
       v.setElement(i, x);
     }
Parameters:
lo first (0-based) index of locally owned elements
hi one more than the last (0-based) index of locally owned elements
template<typename T, typename I = int>
IdxType gridpack::math::BaseVectorInterface< T, I >::localSize ( void   )  const

Get the local length.

Returns:
local vector length
template<typename T, typename I = int>
double gridpack::math::BaseVectorInterface< T, I >::norm1 ( void   )  const

Compute the vector L1 norm (sum of absolute value).

template<typename T, typename I = int>
double gridpack::math::BaseVectorInterface< T, I >::norm2 ( void   )  const

Compute the vector L2 norm (root of sum of squares).

template<typename T, typename I = int>
double gridpack::math::BaseVectorInterface< T, I >::normInfinity ( void   )  const

Compute the infinity (or maximum) norm.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::print ( const char *  filename = NULL  )  const

Print to named file or standard output.

Collective.

The format is dependent on the specific vector implementation.

Parameters:
filename optional file
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::ready ( void   ) 

Make this instance ready to use.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::real ( void   ) 

Replace all elements with their real part.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::reciprocal ( void   ) 

Replace all elements with its reciprocal.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::save ( const char *  filename  )  const

Save, in MatLAB format, to named file (collective).

Collective.

Parameters:
filename 
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::saveBinary ( const char *  filename  )  const

Save to named file in whatever binary format the math library uses.

Collective.

The underlying math library generally supports some way to save a Vector to a file. This routine uses whatever format that can be read by loadBinary().

Parameters:
filename 
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::scale ( const TheType x  ) 

Scale all elements by a single value.

template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::setElement ( const IdxType i,
const TheType x 
)

Set an individual element.

Local.

This overwrites the value at the specified index. ready() must be called after all setElement() calls and before using the vector.

Parameters:
i element global (0-based) index
x value to place in vector
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::setElementRange ( const IdxType lo,
const IdxType hi,
TheType x 
)

Set a range of elements (lo to hi-1).

Local.

An example that fills the locally owned part of the vector:

 {.cpp}
 Vector v(...);
 int lo, hi;
 v.local_index_range(lo, hi);
 std::vector<ComplexType> x(v.local_size())
 // fill x with appropriate values
 v.setElement_range(lo, hi, &x[0]);
Parameters:
lo lowest global (0-based) index to fill
hi one more than the highest global (0-based) index to fill
x array of hi - lo values
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::setElements ( const IdxType n,
const IdxType i,
const TheType x 
)

Set an several elements.

Local.

This places (overwrites) several elements, with arbitrary indexes, in the vector. ready() must be called after all setElement() calls and before using the vector.

Parameters:
n number of elements to place in vector
i pointer to an array of n global (0-based) indexes
x pointer to an arry
template<typename T, typename I = int>
IdxType gridpack::math::BaseVectorInterface< T, I >::size ( void   )  const

Get the global length.

Returns:
global vector length
template<typename T, typename I = int>
void gridpack::math::BaseVectorInterface< T, I >::zero ( void   ) 

Make all the elements zero.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 3 Feb 2020 for GridPACK by  doxygen 1.6.1